Skip to content

feat: Change default listen address to 0.0.0.0#2307

Merged
simon-lemay-unity merged 15 commits intodevelopfrom
feat/default-listen-address
Nov 21, 2022
Merged

feat: Change default listen address to 0.0.0.0#2307
simon-lemay-unity merged 15 commits intodevelopfrom
feat/default-listen-address

Conversation

@simon-lemay-unity
Copy link
Copy Markdown
Contributor

Change the default listen address to 0.0.0.0, instead of falling back on the 'Address' field. This should simplify things for users setting up connections to other machines, since the default will now be what you usually want for a server.

Changelog

  • Changed: The default listen address of UnityTransport is now 0.0.0.0.

Testing and Documentation

  • No tests have been added.
  • No documentation changes or additions were necessary.

@simon-lemay-unity simon-lemay-unity enabled auto-merge (squash) November 16, 2022 15:20
Comment thread com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs Outdated
Comment thread com.unity.netcode.gameobjects/Tests/Editor/Transports/UnityTransportTests.cs Outdated
simon-lemay-unity and others added 2 commits November 16, 2022 12:11
…nsportTests.cs

Co-authored-by: Jesse Olmer <jesseo@unity3d.com>
…sport.cs

Co-authored-by: Jesse Olmer <jesseo@unity3d.com>
{
get
{
if (ServerListenAddress?.Length == 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this log Debug.LogError($"Invalid network endpoint: {ip}:{port}."); in the case where the server listen address is empty?

I don't see an actual test case for this conditional - do we have one for an empty address versus a malformed one?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather, line 339 (accessing ServerEndPoint) would log this in this case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if both the 'Address' and 'Listen Address' fields are left empty, it will log an error. Although that scenario was never supported before. The previous behavior if leaving 'Listen Address' empty was to use 'Address'. I can add a special case where if both are left empty, we revert to 0.0.0.0 as the listen address.

There are no specific tests for leaving the listen address empty, but that is what a lot of tests actually end up doing, since it's the default when calling SetConnectionData without explicitly setting a listen address.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a change that avoids an error if both 'Address' and 'Listen Address' are empty (we'll then default to 0.0.0.0). Also added a test case for this particular scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants